/* 
 * File:   Rational.h
 * Purpose:
 * Contains structure definition and procedures for manipulating Rational Numbers
 * Author: abhi
 *
 * Created on September 18, 2011, 11:56 AM
 */

#ifndef RATIONAL_H
#define	RATIONAL_H

#ifdef	__cplusplus
extern "C" {
#endif

    /* struct for Rational Number */
    typedef struct s_rational {
        int numerator;
        int denominator;
    } rational;

    /* functions */

    /* Arithmetic Operations */
    extern rational rAdd(rational arg1, rational arg2);
    extern rational rSub(rational arg1, rational arg2);
    extern rational rMul(rational arg1, rational arg2);
    extern rational rDiv(rational arg1, rational arg2);
    
    /* Comparison Operations */
    extern int rE(rational arg1, rational arg2);
    extern int rLt(rational arg1, rational arg2);
    extern int rGt(rational arg1, rational arg2);
    extern int rLtE(rational arg1, rational arg2);
    extern int rGtE(rational arg1, rational arg2);
    
    /* Conversion Operations */
    extern rational itor(int intNum);
    
    /* Error Handling Operations*/
    extern int rError(void);
    extern rational rNull(void);
    extern int rCheckNull(rational num);
    
    extern int rCheckValid(rational num);
    extern rational rCheckNegative(rational num);
    
    /* Display Procedures */
    extern void printRational(rational num);
    
    /* Other utility operations */
    extern rational rReduce(rational num);
    extern int gcd(int arg1, int arg2);

#ifdef	__cplusplus
}
#endif

#endif	/* RATIONAL_H */

